//
//  lishiTableViewCell.swift
//  BusinessIOS
//
//  Created by Rain on 2019/1/24.
//  Copyright © 2019 XingJian Li. All rights reserved.
//

import UIKit

class lishiTableViewCell: UITableViewCell {
    
    var photoImage:UIImageView!
    
    var timeLabel:UILabel!
    
    var nameLabel:UILabel!
    
    var leixingLabel:UILabel!
    
    var wentiLabel:UILabel!
    
    
    
    required init?(coder aDecoder: NSCoder) {
        
        super.init(coder: aDecoder)
        
    }
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.lauoutUI()
        
    }
    func lauoutUI(){
        
        
        photoImage = UIImageView(image: UIImage(named: "morentouxiang"))
        
        self.contentView.addSubview(photoImage)
        
        
        timeLabel = UILabel()
    
        timeLabel.text = "12-29 03:43"
        timeLabel.textAlignment = .center
        timeLabel.font = UIFont.systemFont(ofSize:12)//一般方法
        self.contentView.addSubview(self.timeLabel!)
        
        
        nameLabel = UILabel()
  
        nameLabel.text = "国土局"
        nameLabel.textAlignment = .left
        nameLabel.font = UIFont.systemFont(ofSize:15)//一般方法
        self.contentView.addSubview(self.nameLabel!)
        
        
        leixingLabel = UILabel()
     
        leixingLabel.text = "类型:市"
        leixingLabel.textAlignment = .left
        leixingLabel.font = UIFont.systemFont(ofSize:12)//一般方法
        self.contentView.addSubview(self.leixingLabel!)
        
        
        wentiLabel = UILabel()
     
        wentiLabel.text = "问题与困难:徒大声道是发送发送到啊"
        wentiLabel.textAlignment = .left
        wentiLabel.font = UIFont.systemFont(ofSize:12)//一般方法
        self.contentView.addSubview(self.wentiLabel!)
        
        
        self.layoutView()
        
        
    }
    
    // 赋值方法 - 显示 cell 内容方法
    func lishiWithModel(model: lishiModel) {
        
       self.timeLabel.text = model.createtime
        self.nameLabel.text = model.departmentName
        self.leixingLabel.text = "类:\(model.questionLevel!)"
        self.wentiLabel.text = "问题描述:\(model.questionDesp!)"
//        titleLabel.text = "投资动态"
//        nameLabel.text = model.title
//
//        timeLabel.text = model.createtime
        
        
    }
    
    func layoutView() {
        
        self.photoImage.snp.makeConstraints { (make) in
            make.top.equalTo(self.snp.top).offset(5)
            make.left.equalTo(self.snp.left).offset(10)
            make.width.equalTo(40)
            make.height.equalTo(40)
        }
        
       
        
        self.timeLabel.snp.makeConstraints { (make) in
            
            
            make.top.equalTo(self.snp.top).offset(5)
            make.width.equalTo(140)
            make.right.equalTo(self.snp.right).offset(-10)
            make.height.equalTo(20)
        }
        
        
        self.nameLabel.snp.makeConstraints { (make) in
            make.top.equalTo(self.snp.top).offset(5)
            make.left.equalTo(self.photoImage.snp.right).offset(10)
            make.width.equalTo(100)
            make.height.equalTo(20)
        }
        
        self.leixingLabel.snp.makeConstraints { (make) in
            make.top.equalTo(self.nameLabel.snp.bottom).offset(5)
            make.left.equalTo(self.photoImage.snp.right).offset(10)
            make.right.equalTo(self.snp.right).offset(-10)
            make.height.equalTo(20)
        }
        
        
        self.wentiLabel.snp.makeConstraints { (make) in
            make.top.equalTo(self.leixingLabel.snp.bottom).offset(5)
            make.left.equalTo(self.photoImage.snp.right).offset(10)
            make.right.equalTo(self.snp.right).offset(-10)
            make.height.equalTo(30)
        }
        
        
        
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
